import java.io.*;
import java.util.*;
import local.util.MyPrint;

/******************************************************************
 * This programme will take html file as input and remove <Script>
 * tage and output each line start with "<"
 *
 ******************************************************************/

public class CleanHtmlFile  {

    private File name = null;
    private static Hashtable hashTab = new Hashtable ();

    public void setFileName( String fileName )
    {
	name = new File (fileName);
    }

    public void loadHtmlFile () {

        if ( !name.exists() ) {
	   System.out.println("File:"+name.getName()+" not found!");
	   return;
       }

       if ( name.isFile() ) {
	   try {
               RandomAccessFile r =  new RandomAccessFile( name, "r" );
               String text=""; 
	       StringBuffer tempBf = new StringBuffer(); 

               while(( text = r.readLine() ) != null ) {
		   text = text.replaceAll(">",">\n");
		   text = text.replaceAll("</OPTION>","");
		   text = text.replaceAll("<OPTION","");
		   text = text.replaceAll(">","");
		   text = text.replaceAll(" VALUE=","");
		   tempBf.append(text);
	       }
	       String temp1, temp2;
	       StringTokenizer tokens = new StringTokenizer(tempBf.toString(), "\n");
	       while (tokens.hasMoreTokens()) {
		   temp1 = (String)tokens.nextToken();
		   temp2 = (String)tokens.nextToken();
		   hashTab.put(temp1, temp2);
	       }

	        MyPrint.printHashTable(hashTab);
	   }
	   catch( IOException e ) {

	   }
       }
    }

    public static void main (String args[]) {
	CleanHtmlFile clean = new CleanHtmlFile ();
	clean.setFileName(args[0]);
	clean.loadHtmlFile();
    }
}



